<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "yyh_task".
 *
 * @property int $id ID
 * @property int $user_id 咨询
 * @property int $task_num 任务数
 * @property string $yearmonth 年-月
 * @property string $createtime 创建时间
 * @property string $lastupdatetime 最后更新时间
 */
class Task extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'yyh_task';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['user_id', 'task_num', 'yearmonth', 'createtime', 'lastupdatetime'], 'required'],
            [['user_id', 'task_num'], 'integer'],
            [['yearmonth', 'createtime', 'lastupdatetime'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'user_id' => '咨询',
            'task_num' => '任务数',
            'yearmonth' => '年-月',
            'createtime' => '创建时间',
            'lastupdatetime' => '最后更新时间',
        ];
    }

    public function getShowname()
    {
        $user = User::findOne($this->user_id);
        if (null != $user) {
            return $user->showname;
        }
        return null;
    }

    public function getUser()
    {
        return User::findOne($this->user_id);
    }
}
